import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        count: 1,
        token: '',
        network: true
    },
    getters: {
        getStateCount: function (state) {
            return state.count + 1;
        }
    },
    mutations: {
        add:function (state,n) {
            state.count += n;
        },
        desc: function (state,n) {
            state.count -= n;
        }
    },
    actions: {
        add: function (context,n) {
            context.commit('add',n);
        },
        desc: function (context,n) {
            context.commit('desc',n);
        }
    }
});

export default store;
